package View;

import Controller.InitController;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;

/**
 *
 * @author elach_000
 */

public class MainView extends JFrame{

    private javax.swing.JButton launchButton;
    private javax.swing.JButton demoButton;
    private javax.swing.JButton debugButton;
    private javax.swing.JPanel buttonPanel;
    private ParamPanel paramPanel;
    private InitController init;
    
    
    public MainView(InitController init) {
        this.init = init;
        initComponents();
    }

    private void initComponents() {

        //Init Components
        launchButton = new javax.swing.JButton();
        demoButton = new javax.swing.JButton();
        debugButton = new javax.swing.JButton();
        buttonPanel = new JPanel();
        paramPanel = new ParamPanel();
        
        //Settings of the frame
        setTitle("Projet IA");
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setSize(300, 300);
        setLocationRelativeTo(null);
        setVisible(true);
        setResizable(false);       
        this.setLayout(new BorderLayout());
        //Config Components
        
        this.add(paramPanel,BorderLayout.CENTER);
        
        buttonPanel.setLayout(new FlowLayout());
        
        launchButton.setText("Start");
        launchButton.addActionListener(new java.awt.event.ActionListener() {        
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                    launchButtonActionPerformed(evt);
            }
        });        
        buttonPanel.add(launchButton);
        
        demoButton.setText("Wesh");
        demoButton.addActionListener(new java.awt.event.ActionListener() {        
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                    demoButtonActionPerformed(evt);
            }
        });
        //buttonPanel.add(demoButton);
        
        debugButton.setText("Debug Mode");
        debugButton.addActionListener(new java.awt.event.ActionListener() {        
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                    debugButtonActionPerformed(evt);
            }
        });
        //buttonPanel.add(debugButton);
        
        this.add(buttonPanel,BorderLayout.PAGE_END);

        pack();
    }
    
              
    private void debugButtonActionPerformed(java.awt.event.ActionEvent evt) {
        this.setVisible(false);
        this.init.startGame("debug");       
    }
    
    private void launchButtonActionPerformed(java.awt.event.ActionEvent evt) {
        this.setVisible(false);
        this.init.startGame("normal");
       
    }
                  
    private void demoButtonActionPerformed(java.awt.event.ActionEvent evt) {
        this.setVisible(false);
        this.init.startGame("demo");     
    }

    public ParamPanel getParamPanel() {
        return paramPanel;
    }

    
    
    
}
